//
//  LFBDetailProductInfoController.m
//  loveFreshBeen
//
//  Created by Feng on 2017/7/11.
//  Copyright © 2017年 feng. All rights reserved.
//

#import "LFBDetailProductInfoController.h"
#import "LFBDetailProductInfoView.h"
#import "LFBshoppingCartToolBarView.h"
#import "LFBShoppingCartManager.h"
#import <Masonry.h>

@interface LFBDetailProductInfoController ()

//@property(nonatomic,strong) LFBDetailProductInfoView *detailProductInfoView;

@end

@implementation LFBDetailProductInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //1.添加tableView
    [self setupTableView];
    //2.添加购物车视图LFBshoppingCartToolBarView
    [self setupShoppingCartToolBarView];
}

- (void)setupTableView
{
    UITableView *tableView = [[UITableView alloc] init];
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    //1.创建一个view
    LFBDetailProductInfoView *detailProductInfoView = [LFBDetailProductInfoView detailProductInfoView];
    detailProductInfoView.model = self.shoppingCartModel;
//    self.detailProductInfoView = detailProductInfoView;
    
    //4.将view 设置为tableView的footerView
    tableView.tableFooterView = detailProductInfoView;
    
    [detailProductInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view).offset(0);
    }];
}

- (void)setupShoppingCartToolBarView
{
    //1.添加到self.view的底部
    LFBshoppingCartToolBarView *toolBarView = [LFBshoppingCartToolBarView shoppingCartToolBarView];
    toolBarView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:toolBarView];
    [toolBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.offset(0);
        make.height.offset(60);
    }];
    
    //设置模型model
    toolBarView.model = self.shoppingCartModel;
    
    //设置角标
    NSString *numStr = [NSString stringWithFormat:@"%zd",[LFBShoppingCartManager sharedManager].sumNums];
    NSLog(@"%@",numStr);
    [toolBarView.productNums setTitle:numStr forState:UIControlStateNormal];
}

@end
